home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 09, No. 11 (1988-11)(MicroSPARC)(Side A)[a].zip / Nibble Volume 09, No. 11 (1988-11)(MicroSPARC)(Side A)[a].po / START.PGM.ASM.txt < prev    next >
Text File  |  1996-12-24  |  5KB  |  137 lines

  1. ***********************************
  2. *                                 *
  3. *         */SYSTEM/START          *
  4. *          Program Code           *
  5. *  Interpreted by Sandy Mossberg  *
  6. *                                 *
  7. *       Copyright (C) 1988        *
  8. *       by MicroSPARC, Inc.       *
  9. *       Concord, MA  01742        *
  10. *                                 *
  11. ***********************************
  12.  
  13. ; Equate:
  14.  
  15. PRODOS     GEQU     $E100A8          ;ProDOS 16 call
  16.  
  17. Start_File START
  18.  
  19. ; Equate data bank to program bank:
  20.  
  21. Start_Body PHK
  22.            PLB
  23.  
  24. ; Calculate amount of usable RAM
  25.  
  26.            PHA                       ;reserve work area on
  27.            PHA                       ; stack (4 bytes)
  28.            JSL      >GoGetRAM        ;get size of usable RAM
  29.            LDA      $03,S            ;result left on stack
  30.            CMP      #4
  31.            BCC      AltQuit          ;less than 256K found
  32.  
  33. ; Primary QUIT command:
  34.  
  35.            JSL      PRODOS           ;used if >= 256K usable RAM
  36.            DC       I2'$29'          ;QUIT command code
  37. MQParmPtr  DC       I4'MQuitParm'    ;pointer to parmlist
  38.  
  39. ; Alternate QUIT command:
  40.  
  41. AltQuit    JSL      PRODOS           ;used if < 256K usable RAM
  42.            DC       I2'$29'          ;QUIT command code
  43. AQParmPtr  DC       I4'AQuitParm'    ;pointer to parmlist
  44.  
  45. ; Primary QUIT parameter list:
  46.  
  47. MQuitParm  DC       I4'MQuitName'    ;pointer to pathname
  48.            DC       I2'$00'          ;return/restart flags
  49.  
  50. ; Alternate QUIT parameter list:
  51.  
  52. AQuitParm  DC       I4'AQuitName'    ;pointer to pathname
  53.            DC       I2'$00'          ;return/restart flags
  54.  
  55. ; Pathname of primary START file:
  56.  
  57. MQuitName  DC       I1'$0F'          ;length byte
  58.            DC       C'*/SYSTEM/FINDER'
  59.  
  60. ; Pathname of alternate START file:
  61.  
  62. AQuitName  DC       I1'$11'          ;length byte
  63.            DC       C'*/SYSTEM/LAUNCHER'
  64.  
  65. ; Call subroutine to calculate usable RAM:
  66. ;
  67. ; EXIT: usable RAM on stack bytes 1-4 (L-ML-MH-H):
  68.  
  69. GoGetRAM   JSL      >GetRAM          ;get size of unpurgeable RAM
  70.            RTL
  71.  
  72. ; Subroutine to calculate usable RAM:
  73. ;
  74. ; EXIT: usable RAM on stack bytes 4-7 (L-ML-MH-H):
  75.  
  76. ;--> Transform stack into work area for calculations:
  77.  
  78. GetRAM     PHD                       ;save entry direct page
  79.            PHA                       ;save return address
  80.            PHA                       ; on stack
  81.            TSC                       ;equate stack and
  82.            TCD                       ; direct page
  83.            STZ      $0D              ;zero storage bytes for
  84.            STZ      $0F              ; RAM calculations
  85.  
  86. ;--> Point to Memory Manager's allocated block records:
  87.  
  88.            LDA      $E11600
  89.            TAX
  90.            LDA      $E11602
  91. GR1        STX      $01              ;pointers to block records
  92.            STA      $03              ; at $00-$03
  93.  
  94. ;--> Test block attributes:
  95.  
  96.            LDY      #4
  97.            LDA      [$01],Y          ;get attributes
  98.            AND      #$0300           ;isolate purge level
  99.            BNE      GR2              ;block purgeable so skip it
  100.  
  101. ;--> Calculate total size of unpurgeable (unusable) RAM:
  102.  
  103.            LDY      #8               ;block unpurgeable
  104.            LDA      [$01],Y          ;get block size lo
  105.            CLC                       ; and save it
  106.            ADC      $0D              ; at $0C-$0D of
  107.            STA      $0D              ; direct page (also stack)
  108.            INY                       ;bump index to
  109.            INY                       ; hi order byte
  110.            LDA      [$01],Y          ;get block size hi
  111.            ADC      $0F              ; and save it
  112.            STA      $0F              ; at $0E-$0F of
  113. GR2        LDY      #$10             ; direct page (also stack)
  114.            LDA      [$01],Y          ;get link lo to next
  115.            TAX                       ; block record
  116.            INY                       ;bump index to
  117.            INY                       ; hi order byte
  118.            LDA      [$01],Y          ;get link to to next record
  119.            BNE      GR1              ;not at last record
  120.  
  121. ;--> Subtract from $100000000 to get total usable RAM:
  122.  
  123.            LDA      #0               ;all block records checked
  124.            TAX                       ; so calculate complement
  125.            SEC                       ; of total block sizes
  126.            SBC      $0D              ; stored at $0C-$0F
  127.            STA      $0D
  128.            TXA
  129.            SBC      $0F
  130.            STA      $0F
  131.            PLA                       ;restore return address and
  132.            PLA                       ; direct page to entry
  133.            PLD                       ; values (former $0C-$0F at
  134.            RTL                       ; $04-$07 after  RTL)
  135.  
  136.            END
  137.